package com.meiborte.controller;

import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class SessionController {

    //往会话对象Session中存储数据
    @GetMapping("/s1")
    public String s1(HttpSession session) {
        session.setAttribute("username", "zhangsan");
        session.setAttribute("password", "123456");

        return "ok";
    }

    //从会话对象Session中获取数据
    @GetMapping("/s2")
    public String s2(HttpSession session) {
        Object username = session.getAttribute("username");
        Object password = session.getAttribute("password");
        System.out.println(username + "--" + password);
        return "ok";
    }
}
